package com.wuchao.spring.mybatisAndSpring;

import com.github.pagehelper.PageInfo;
import com.wuchao.mapper.ManMapper;
import com.wuchao.mapper.TypeMapper;
import com.wuchao.pojo.Man;
import com.wuchao.pojo.Type;
import com.wuchao.pojo.Users;
import com.wuchao.service.serviceImpl.UsersServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author wuchao66
 * @Date 2022/9/29 10:23
 * @PackageName:com.wuchao.spring.mybatisAndSpring
 * @ClassName: Test
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
@Slf4j
public class Test {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext cpxc = new ClassPathXmlApplicationContext("ApplicationContextProMax.xml");
       //事务测试
        ((Point162)cpxc.getBean("Point162")).show();
        //分页
        PageInfo<Users> page = ((UsersServiceImpl) cpxc.
                getBean("usersServiceImpl")).findUsersAndTypeBynameConcatByPage(1, 3, "");
        page.getList().forEach(System.out::println);


        //测试专门扫mapper 专门扫的，不需要写名字，但是默认骆驼法
        Type type = ((TypeMapper) cpxc.getBean("typeMapper")).selectByPrimaryKey(3);
        log.info(type.getName());
        //拿到多少系统自定好的bean名
        String[] beanDefinitionNames = cpxc.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            log.info(beanDefinitionName+"\n");
        }
    }
}
